var express = require("express");
var router = express.Router();
var db = require("../db/db");
const { pinyin } = require("pinyin-pro");

router.get("/user", async (req, res, next) => {
  let result = await db.query("select * from user");
  result.forEach((item) => {
    item.createtime = global
      .moment(item.createtime)
      .format("YYYY-MM-DD HH:mm:ss");
  });
  res.send(result);
});


router.get('/pinyin',async (req,res,next)=>{
  let {name} =req.query
  console.log(name)
  let msg = pinyin(name, { pattern: "first", type: "array" }).join('');
  res.jsonp({
    code: 200,
    message: msg,
  });

})
module.exports = router;
